<template>
	<view :style="{height: height}">
		
		<view class="nav">
			<!-- <image src="../../static/18.png" class="logo" mode="widthFix"></image> -->
			<view style="margin: 0 34upx;font-size: 38upx;color: #fff;margin-top: 240upx;height: 70upx;line-height: 70upx;">
				您好 !
			</view>
			<view style="margin: 0 34upx;font-size: 44upx;color: #fff;">
				欢迎回来
			</view>
		</view>
		
		<view class="content">
			<view class="webkit input" style="margin-top: 100upx;">
				<image src="../../static/shouji.png"></image>
				<input class="flex" type="text" v-model="mobile" placeholder-style="color:#aaa" placeholder="请输入您的手机号"/>
			</view>
			<view class="webkit input">
				<image src="../../static/pass1.png"></image>
				<input class="flex" type="text" placeholder-style="color:#aaa" v-model="pwd" password  placeholder="请输入您的密码"/>
			</view>
			<button type="warn" style="background-color: #05052B;" :loading="loading" @click="login">登录</button>
		</view>
		
		<view class="action-row">
			<!-- <navigator url="../reg/reg">注册账号</navigator> -->
			<!-- <text>|</text> -->
			<navigator url="forget/forget" >忘记密码</navigator>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				width:0,
				height:0,
				mobile:'',
				pwd:'',
				systemInfo:{},
				loading:false,
				openid:[],
				error:'',
			};
		},
		onLoad:function(){
			uni.hideLoading();
			uni.getSystemInfo({
				success: (res) => {
					this.systemInfo = res
					this.width = res.windowWidth
					this.height = res.windowHeight
				}
			})
		},
		onBackPress(options) {
				this.back();  
				return true;  
		},  
		methods: {
			login(){
				this.loading = true
				if(this.mobile == ""){
					this.loading=false
					uni.showToast({
						title: '请输入手机号',
						icon:"none"
					});
				}else if(this.pwd == ""){
					this.loading = false
					uni.showToast({
						title: '请输入密码',
						icon:"none"
					});
				}else{
					var data = {
							'mobile': this.mobile,
							'pwd': this.pwd,
						}
						console.log(JSON.stringify(data))
					uni.request({
						url: 'http://adkk.mygodmall.com/app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=account.login&app=1',
						method: 'POST',
						data: data,
						header:{'Content-Type':'application/x-www-form-urlencoded'},
						success: res => {
							// console.log(JSON.stringify(res));return false;
							if(res.data.status == 0){
								uni.showToast({
									title: res.data.result.message,
									icon:"none"
								});
								this.loading = false
							}else{
								uni.setStorage({
									key: 'openid',
									data: res.data.result.openid,
									success: (res) => {},
									fail: () => {}
								})
								uni.setStorage({
									key: 'mid',
									data: res.data.result.mid,
									success: (res) => {},
									fail: () => {}
								})
								setTimeout(()=>{
									this.loading = false
									uni.reLaunch({
										url: '../member/member'
									});
								},500)
							}
						},
						fail: () => {},
						complete: () => {}
					});
				}
			},
			back(){
				uni.reLaunch({
					url: '../home/home'
				});
			},
			jump(e){
				uni.navigateTo({
					url: e.currentTarget.dataset.src
				});
			},
		}
	}
</script>

<style>
	page {background-color:#fff;}
	image {width:240upx;height:240upx;}
	button {margin:60upx 30upx 20upx;}
	.nav {width: 100%;height: 500upx;background: #05052B;position: relative;overflow: hidden;}
	.logo {display:block;position: absolute;right: 30upx;top: 90upx;width: 260upx;}
	.content {width:100%;height: 500upx;border-radius: 60upx 60upx 0 0;overflow: hidden;position: relative;margin-top: -60upx;background: #fff;}
	.input {border-bottom:1px solid #f0f0f0;margin:0 30upx;}
	.input image {width:50upx;height:50upx;margin-left:20upx;margin-right:10upx;margin-top:15upx;}
	.input input {line-height:80upx;font-size:28upx;height:80upx;}
	.btn-group{margin:0 30upx;}
	.btn-group view {color:#999;}
	.action-row {
		display: flex;
		flex-direction: row;
		justify-content: center;
	  color: $uni-color-error;
		font-size: 26upx;
	}
	
	.action-row navigator {
	  color: $uni-color-error;
		padding: 0 10px;
	}
</style>
